#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef int bool;
#define true 1
#define false 0

void readStr(char *target)
{
    scanf("%s", target);
}

bool isSubsequence(char *s, char *t);
unsigned char dp[500000];
char gt[500000 + 1];
char gs[100 + 1];
int main()
{
    memset(dp, 0, 500000 * sizeof(unsigned char));

    readStr(gs);
    readStr(gt);
    bool ok = isSubsequence(gs, gt);
    printf("%d\n", ok);
}
bool isSubsequence(char *s, char *t)
{
    if (strlen(s) == 0)
    {
        return true;
    }
    if (strlen(t) == 0)
    {
        return false;
    }

    memset(dp, 0, 500000 * sizeof(char));
    int lenofs = strlen(s);
    if (t[0] == s[0])
    {
        dp[0] = 1;
    }
    if (dp[0] == lenofs)
    {
        return true;
    }
    int lenoft = strlen(t);
    int i = 1;
    for (; i != lenoft; i++)
    {
        if (t[i] == s[dp[i - 1]])
        {
            dp[i] = dp[i - 1] + 1;
        }
        else
        {
            dp[i] = dp[i - 1];
        }
        if (dp[i] == lenofs)
        {
            return true;
        }
    }
    printf("%d i\n", i);
    return false;
}